package com.qcu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qcu.dto.chart.AppointOfDoctor;
import com.qcu.entity.Appointment;
import com.qcu.vo.AppointmentInfoTDVO;
import com.qcu.vo.AppointmentInfoVO;
import com.qcu.vo.DepartmentVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author MyComputer
* @description 针对表【appointment】的数据库操作Mapper
* @createDate 2025-02-11 15:50:27
* @Entity com.qcu.entity.Appointment
*/
public interface AppointmentMapper extends BaseMapper<Appointment> {

//    @Select("select d.id as id , d.name as type_name , s.staff_id as staff_id ,  concat(s.first_name,s.last_name) as real_name , s.type as type\n" +
//            "from staff_account as s \n" +
//            "left join doctor_menu as d on s.type = d.id \n" +
//            "where s.staff_id != 1\n")
    List<DepartmentVO> getDWD();
    @Select("select i.name as name , i.gender , d.name as item ,concat(s.first_name,s.last_name) as doctor_name , a.sub_time as time , a.subscribe as subscribe , a.state as state\n" +
            "from appointment as a\n" +
            "left join inhabitant as i on a.inhabitant_id = i.id\n" +
            "left join staff_account as s on a.doctor_id = s.staff_id\n" +
            "left join doctor_menu as d on a.item = d.id\n" +
            "where i.user_id = #{id}")
    List<AppointmentInfoVO> getITU(Integer id);
    @Select("select a.id as id , i.name as name , i.gender , d.name as item  , a.sub_time as time , a.subscribe as subscribe , a.email ,a.state as state\n" +
            "from appointment as a\n" +
            "left join inhabitant as i on a.inhabitant_id = i.id\n" +
            "left join staff_account as s on a.doctor_id = s.staff_id\n" +
            "left join doctor_menu as d on a.item = d.id\n" +
            "where a.doctor_id = #{id}")
    List<AppointmentInfoTDVO> getITD(Integer id);

    @Select("select concat(s.first_name,s.last_name) as name , count(a.doctor_id) as count from staff_account s left join appointment a on s.staff_id = a.doctor_id group by s.staff_id ")
    List<AppointOfDoctor> getAppoOfDoct();
}




